#--- Создает символьную сылку __destination на __source

function (symlink __source __destination)
	set(__cmd )
	set(__arg )
	if (WIN32)
		set(__cmd "mklink")
	
		if (IS_DIRECTORY ${__source})
			set(__arg "/J ")
		else()
			set(__arg "/H ")
		endif()
		
		STRING(REGEX REPLACE "/" "\\\\" __source ${__source}) 
		STRING(REGEX REPLACE "/" "\\\\" __destination ${__destination}) 
		
		#set(__arg "${__arg} ${__destination} ${__source}")
		
		set (__command "${__cmd} ${__arg} ${__destination} ${__source}")
	else()
		set(__cmd "ln ")
		set(__arg "-s")
		set(__arg "${__arg} ${__destination} ${__source}")
	endif()
	
#	message(STATUS "Symlink command: ${__command}" )
			
	execute_process(COMMAND cmd /c ${__command}
		RESULT_VARIABLE _result_command
		OUTPUT_VARIABLE _out_command
		ERROR_VARIABLE  _err_command 
	)
	
	if(_result_command)
#		message(STATUS "\nLink creation result: ${_result_command}")
	endif()
	
	if(_out_command)
#		message(STATUS "\nLink creation sucseed: ${_out_command}")
	endif()
	
	if(_err_command)
		message(WANING "\nLink creation error:\n"
		"----source = ${__source}\n"
		"----destination = ${__destination}\n"
		"----reason = ${_err_command}"
		)
	endif()
endfunction (symlink)